<?php
/**
 * Created by PhpStorm.
 * User: liuhong
 * Date: 2019-04-09
 * Time: 13:44
 */

namespace app\api\controller;
use app\common\model\Source as SourceModel;
use app\common\model\SourceActive;

class Swiper extends Base
{
    
    /* 轮播列表 */
    public function list () {
        $input = input();
        $where = [
            'type' => 1
        ];
        if($input['type']) {
            $where['type'] = $input['type'];
        }
        $list = SourceModel::getAll($where,$orderby='ord desc');
        if(!$list) {
            $this->ajax(200,'success',[]);
        }
        foreach($list as $k=>$v) {
            $list[$k]['url'] = tomedia($v['url']);
        }
        $this->ajax(200,'success',$list);
    }

    /* 轮播列表 */
    public function active_list () {
        $input = input();
        $where = [
            'type' => 1
        ];
        if($input['type']) {
            $where['type'] = $input['type'];
        }
        $list = SourceActive::getAll($where,$orderby='ord desc');
        if(!$list) {    
            $this->ajax(200,'success',[]);
        }
        foreach($list as $k=>$v) {
            $list[$k]['url'] = tomedia($v['url']);
        }
        $this->ajax(200,'success',$list);
    }

}